Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve DnsDialogViewModel nav arguments #7053

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kl
Copy link
Contributor

@kl kl commented Oct 23, 2024


This change is Reviewable

@kl kl added the Android Issues related to Android label Oct 23, 2024
@kl kl requested a review from Rawa October 23, 2024 14:48
Copy link

linear bot commented Oct 23, 2024

@kl kl force-pushed the improve-dnsdialogviewmodel-arguments-droid-579 branch from ea8d6d9 to 98375f9 Compare October 24, 2024 07:09
Pururun
Pururun previously approved these changes Oct 24, 2024
Copy link
Contributor

@Pururun Pururun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 4 of 4 files at r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

Copy link
Contributor

@Rawa Rawa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 4 of 4 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @kl)


android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/DnsDialogViewModel.kt line 81 at r1 (raw file):

                viewModelScope,
                SharingStarted.Lazily,
                createViewState(emptyList(), null, false, EMPTY_STRING),

I'm a bit torn of this, I think it would be nicer if we directly show the correct state.

Right now if you click on an existing entry we would incorrectly show EMPTY_STRING first. Maybe it is necessary to introduce a loading state?

Some other remarks that I think we can do better:

  • We should review if we can make MutableStateFlow<Settings?> more clear. It doesn't seem to add much in it current form ( except as acting like a cache for the first Settings object we saw to avoid an update as we press save.)
  • _ipAddressInput being nullable feels wrong, it looks like the user can input a "null" but that wouldn't be valid input from a user. (It is a backing field and onDnsInputChange only accepts String, but it gets a bit confusing. Maybe lateinit until we get first Settings?
  • The following line does a lot of heavy lifting and isn't very readable:
                val input =
                    inputAddress
                        ?: navArgs.index?.let { index -> dnsList[index].addressString() }
                        ?: EMPTY_STRING

E.g that if navArgs.index would either be always null or always a value.

Copy link
Contributor

@Rawa Rawa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @kl)

@kl kl marked this pull request as draft October 30, 2024 13:38
@kl kl force-pushed the improve-dnsdialogviewmodel-arguments-droid-579 branch from 98375f9 to 4d4111d Compare October 30, 2024 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android Issues related to Android
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants